<template>
	<view class="imagePage">

		<!-- 推荐好友 -->
		<view class="recommend">
			<view class="sjrz" style="margin: 40rpx auto ;text-align: center;">
				团洗商户入驻
			</view>
			<view class="content">
				<image class="codeTwo" src="../../static/qrCode.png" mode="" @longpress="downloadImage"></image>
				<view class="title">
					<view class="getCode">专属邀请码</view>
					<view class="dash" style="">
					</view>
					<view class="">扫码邀请>推广有礼>权益享受</view>
					<view class="longPush" >长按图片保存到相册</view>
				</view>
			</view>

			<view class="title2">
				<image src="../../static/pushMer.png" mode="widthFix"></image>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				image: '',
				type: 1, // type  1代表是 推荐好友  2代表是 pk胜  3代表是  pk负
				pageData: '',
				userInfo: uni.getStorageSync('userInfo'),
				share: {},
				isType: 0,
				img_hb: ''
			};
		},
		onLoad(el) {
			this.type = el.type
			this.isType = el.isType
			if (this.type == 1) {
				// this.getPageData()
			}
		},
		onShareAppMessage() {
			return {
				title: this.share.title,
				path: this.share.path,
				imageUrl: this.share.imageUrl,
				desc: this.share.desc,
				content: this.share.content,
				success(res) {
					this.$utils.toast('分享成功')
					this.share = {}
					console.log(res)
				},
				fail(res) {
					this.$utils.toast('分享失败')
				}
			}
		},
		methods: {
			// 推荐好友
			getPageData() {
				let that = this
				that.$api.inviteFriends().then(res => {
					that.pageData = res.data.data.img
					// console.log(that.pageData,'that.pageData')
					that.img_hb = res.data.data.img_hb
				})
			},
			// 点击下载图片
			downloadImage() {
				let that = this
				uni.downloadFile({
					url: that.img_hb,
					success(res) {
						let tempFilePath = res.tempFilePath
						uni.saveImageToPhotosAlbum({
							filePath: tempFilePath,
							success(res1) {
								that.$utils.toast('图片生成成功')
							},
							fail(err) {
								that.$utils.toast('图片生成失败')
							}
						})
					}
				})
			},
		}
	}
</script>

<style lang="less">

	.sjrz {
		text-align: center;
		box-shadow: 0px 0px 5px rgba(151, 151, 151, 0.1);
		box-sizing: border-box;
		border-radius: 5px;
		width: 100%;
		padding: 20rpx;
		background: #fff;
	}


	.title2{
		width:106%;
		image{
			width: 100%;
		}
	}
	.imagePage {
		padding: 20rpx;

		.recommend {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.content {
				box-shadow: 0px 0px 5px rgba(151, 151, 151, 0.1);
				box-sizing: border-box;
				border-radius: 5px;
				background: #fff;
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: center;
				padding: 20rpx;
				.longPush{
					color: #2CB9A4;
				}
				// image {
				// 	width: 100%;
				// 	margin: 20rpx 0;
				// }
			}

			.title {
				width: 100%;
				text-align: center;
				display: flex;
				flex-direction: column;
				align-items: center;

				view {
					line-height: 50rpx;
					font-size: 28rpx;
				}
			}

			
			.getCode{
				margin: 20rpx;
			}
			.dash {
				width: 95%;
				height: 0px;
				/* background: darkgray; */
				margin: 11px 0 15px;
				border: 1px dashed #979797;
			}

			.codeTwo {
				width: 350rpx;
				height: 350rpx;

			}

			.btn {
				height: 96rpx;
				line-height: 96rpx;
				text-align: center;
				border-radius: 16rpx;
				font-size: 28rpx;
				font-weight: 500;
				position: fixed;
			}

			.invitation {
				background: #1FC064;
				color: #fff;
				bottom: 200rpx;
				left: 50%;
				transform: translateX(-50%);
			}

			.generate {
				background: #DCDCDC;
				color: #7F8084;
				bottom: 70rpx;
				left: 50%;
				transform: translateX(-50%);
			}
		}

		.PKWin,
		.PKNegative {
			image {
				width: 100%;
				height: 100%;
			}

			.btn {
				width: 80%;
				height: 96rpx;
				line-height: 96rpx;
				text-align: center;
				border-radius: 96rpx;
				font-size: 28rpx;
				font-weight: 500;
				position: fixed;
				background: #000;
				color: #fff;
				bottom: 240rpx;
				left: 50%;
				transform: translateX(-50%);
			}
		}

	}
</style>